<?php
	/**
	 * Holds the basic configuration to connect to the database	 
	 */
	define('ENV', 'dev');
	$database = array();
	switch (ENV) {
		case 'prod':
			$database_config['host'] = '';
			$database_config['username'] = '';
			$database_config['password'] = '';
			$database_config['database'] = '';
			break;
		case 'dev':
			$database_config['host'] = '';
			$database_config['username'] = '';
			$database_config['password'] = '';
			$database_config['database'] = '';
			break;
	}
	$connect = mysql_connect($database_config['host'], $database_config['username'], $database_config['password']);
	if (!$connect) {
		if (ENV === 'env')
			die('<p style="background-color: yellow;">Problems connecting to server: ' . mysql_error() . '</p>');
	}
	$selectDB = mysql_select_db($database_config['database'], $connect);
	if (!$selectDB) {
		if (ENV === 'env')
			die('<p style="background-color: yellow;">Can\'t connect to database : ' . mysql_error() . '</p>');
	}
	$contentType_text_html = 'Content-Type: text/html';
	$contentType_Javascript = 'Content-Type: text/javascript';
	$cache = 'Cache-Control: no-cache';
	$pragma = 'Pragma: no-cache';	
	$salt = 'yF18NZSTzbJsx9h9fwWdsIPLn55Q8cwu7opTKxUUSsWNz6UU2wwEKQfb2m4Q9TR8bCiEm3eaVqd2.SliVNaH_tYODDA61Kt2m4';
	
	/**
	 * Generates a 100 characther token string then hashes it using SHA1
	 */
	function generate_token() {
		$haystack = 'abcdefghijklmnopqrstuwxyz_0123456789.QWERTYUIOPASDFGHJKLZXCVBNM';
		$token = '';
		for ($i = 0; $i < 100; $i++) {
			$pos = rand(0, strlen($haystack));
			$token .=  substr($haystack, $pos, 1);
		}		
		return sha1($token);
	}